package com.example.user.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;



import java.io.Serializable;
import java.sql.Date;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {
    private Long id;

    private String usercode;

    private String username;

    private String userpassword;

    private Integer gender;

    private Date birthday;

    private String phone;

    private String address;

    private Integer userrole;

    private Long createdby;

    private Date creationdate;

    private Long modifyby;

    private Date modifydate;

    private int age;

    public int getAge() {
        if(birthday!=null){
            java.util.Date date=new java.util.Date();
            java.sql.Date date1=  new Date(date.getTime());
            return date1.getYear()-birthday.getYear();
        }
        return 18;
    }
    public void setAge(int age) {
        this.age = age;
    }
}